* Data analysis by sector

* Note: must select sectors manually

	version 15
	
* Declare panel and ensure sort
	xtset ein year_soi
	sort ein year_soi
	
* Nix IVs for 2013-2019 for safety
	recode years_of_na_dummy fundr_ratio_dummy admin_ratio_dummy profit_ratio_dummy int_exp_ratio_dummy hhi_abs_dummy (nonmissing = .) if year_soi > 2012

* Clean up if needed
	// drop sample* _est*
	
* By sector, looping manually (ntmaj5; AR=Arts, culture, and humanities; ED=Education; HE=Health; HU=Human services; OT=Other)
	preserve
	drop sample_Omni
	* keep if ntmaj5 == "AR"
	* keep if ntmaj5 == "ED"
	* keep if ntmaj5 == "HE"
	* keep if ntmaj5 == "HU"
	* keep if ntmaj5 == "OT"

* Obtain cumulative effect estimates in one omnibus model
	xtreg log_total_expenses L(1/10).years_of_na_dummy L(1/10).fundr_ratio_dummy L(1/10).admin_ratio_dummy L(1/10).profit_ratio_dummy L(1/10).int_exp_ratio_dummy L(1/10).hhi_abs_dummy i.year_soi if out_nccs=="IN" & donative==1, fe vce(robust) 
	gen sample_Omni = e(sample)

	* Postestimation: Get cumulative marginal effects for each DV over the lags
		* Years of net assets:
		local yona_effect = _b[L.years_of_na_dummy] + _b[L2.years_of_na_dummy] + _b[L3.years_of_na_dummy] + _b[L4.years_of_na_dummy] + _b[L5.years_of_na_dummy] + _b[L6.years_of_na_dummy] + _b[L7.years_of_na_dummy] + _b[L8.years_of_na_dummy] + _b[L9.years_of_na_dummy] + _b[L10.years_of_na_dummy]
		display `yona_effect'
		* Fundraising expense ratio: 
		local fundr_effect = _b[L.fundr_ratio_dummy] + _b[L2.fundr_ratio_dummy] + _b[L3.fundr_ratio_dummy] + _b[L4.fundr_ratio_dummy] + _b[L5.fundr_ratio_dummy] + _b[L6.fundr_ratio_dummy] + _b[L7.fundr_ratio_dummy] + _b[L8.fundr_ratio_dummy] + _b[L9.fundr_ratio_dummy] + _b[L10.fundr_ratio_dummy]
		display `fundr_effect'
		* Administrative ratio:
		local admin_effect = _b[L.admin_ratio_dummy] + _b[L2.admin_ratio_dummy] + _b[L3.admin_ratio_dummy] + _b[L4.admin_ratio_dummy] + _b[L5.admin_ratio_dummy] + _b[L6.admin_ratio_dummy] + _b[L7.admin_ratio_dummy] + _b[L8.admin_ratio_dummy] + _b[L9.admin_ratio_dummy] + _b[L10.admin_ratio_dummy]
		display `admin_effect'
		* Profit ratio:
		local profit_effect = _b[L.profit_ratio_dummy] + _b[L2.profit_ratio_dummy] + _b[L3.profit_ratio_dummy] + _b[L4.profit_ratio_dummy] + _b[L5.profit_ratio_dummy] + _b[L6.profit_ratio_dummy] + _b[L7.profit_ratio_dummy] + _b[L8.profit_ratio_dummy] + _b[L9.profit_ratio_dummy] + _b[L10.profit_ratio_dummy]
		display `profit_effect'
		* Interest expense ratio:
		local interest_effect = _b[L.int_exp_ratio_dummy] + _b[L2.int_exp_ratio_dummy] + _b[L3.int_exp_ratio_dummy] + _b[L4.int_exp_ratio_dummy] + _b[L5.int_exp_ratio_dummy] + _b[L6.int_exp_ratio_dummy] + _b[L7.int_exp_ratio_dummy] + _b[L8.int_exp_ratio_dummy] + _b[L9.int_exp_ratio_dummy] + _b[L10.int_exp_ratio_dummy]
		display `interest_effect'
		* HHI:
		local hhi_effect = _b[L.hhi_abs_dummy] + _b[L2.hhi_abs_dummy] + _b[L3.hhi_abs_dummy] + _b[L4.hhi_abs_dummy] + _b[L5.hhi_abs_dummy] + _b[L6.hhi_abs_dummy] + _b[L7.hhi_abs_dummy] + _b[L8.hhi_abs_dummy] + _b[L9.hhi_abs_dummy] + _b[L10.hhi_abs_dummy]
		display `hhi_effect'
		display "Total of cumulative effects: " `yona_effect' + `fundr_effect' + `admin_effect' + `profit_effect' + `interest_effect' + `hhi_effect'

	restore

